package com.szbmyoubao.app.utils

import android.content.Context
import android.content.Intent
import androidx.core.app.NotificationManagerCompat
import com.ellecity06.common.utils.appContext

/**
 * @author ellecity06
 * @time 2025/1/10 14:50
 * @des
 */
class NotificationUtils {

    companion object {
        /**
         * 是否已经开启了通知
         */
        @JvmStatic
        fun areNotificationsEnabled(): Boolean {
            return NotificationManagerCompat.from(appContext).areNotificationsEnabled()
        }

        /**
         * 引导用户去开启通知
         */
        @JvmStatic
        fun openNotificationSettingsForApp(context: Context) {
            // Links to this app's notification settings.
            val intent = Intent()
            intent.action = "android.settings.APP_NOTIFICATION_SETTINGS"
            intent.putExtra("app_package", context.packageName)
            intent.putExtra("app_uid", context.applicationInfo.uid)
            // for Android 8 and above
            intent.putExtra("android.provider.extra.APP_PACKAGE", context.packageName)
            context.startActivity(intent)
        }
    }
}